home *** CD-ROM | disk | FTP | other *** search
/ Champak 145 / (Vol 145) Dec 21 2011.iso / Games / hanna-in-a-choppa.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2011-12-21  |  10.5 KB  |  386 lines

  1. function Preloader(baseClip, loadedFrame)
  2. {
  3.    this.loadedFrame = loadedFrame;
  4.    this.baseClip = baseClip;
  5.    this.clip = this.baseClip.createEmptyMovieClip("preloaderClip",this.baseClip.getNextHighestDepth());
  6.    this.clip.preloader = this;
  7.    this.frame = 0;
  8.    this.fractionLoaded = 0;
  9.    this.loadedBytes = 0;
  10.    this.totalBytes = 0;
  11.    this.percentLoaded = 0;
  12.    this.clip.onEnterFrame = this.evtEnterFrame;
  13. }
  14. function setupRightClickMenu(showDeeperbeigeLink)
  15. {
  16.    var _loc2_ = new ContextMenu();
  17.    _loc2_.hideBuiltInItems();
  18.    if(showDeeperbeigeLink || showDeeperbeigeLink == undefined)
  19.    {
  20.       var _loc4_ = new ContextMenuItem("┬⌐2008 deeperbeige.com",function()
  21.       {
  22.          return undefined;
  23.       });
  24.       var _loc3_ = new ContextMenuItem("http://deeperbeige.com",function()
  25.       {
  26.          getUrl("http://deeperbeige.com", "_blank");
  27.       });
  28.       _loc3_.separatorBefore = true;
  29.       _loc2_.customItems.push(_loc4_,_loc3_);
  30.    }
  31.    _root.menu = _loc2_;
  32. }
  33. function siteLockTest(contentID, lockedFrame, successCallback)
  34. {
  35.    if(_root._url.substr(0,5) == "file:")
  36.    {
  37.       return successCallback();
  38.    }
  39.    trace("SiteLock: Testing \'" + contentID + "\'");
  40.    var _loc4_ = new LoadVars();
  41.    var _loc3_ = new LoadVars();
  42.    _loc3_.successCallback = successCallback;
  43.    _loc3_.lockedFrame = lockedFrame;
  44.    _loc3_.onLoad = function(success)
  45.    {
  46.       if(this.allowed == 1 || !success)
  47.       {
  48.          trace("SiteLock: Allowed");
  49.          this.successCallback();
  50.       }
  51.       else
  52.       {
  53.          trace("SiteLock: Failed");
  54.          _root.legalURL = this.legalURL;
  55.          _root.gotoAndStop(this.lockedFrame);
  56.       }
  57.    };
  58.    _loc4_.contentID = contentID;
  59.    _loc4_.hostURL = _root._url;
  60.    _loc4_.r = Math.floor(Math.random() * 10000);
  61.    _loc4_.sendAndLoad("http://deeperbeige.com/sitelock/check.php",_loc3_,"POST");
  62. }
  63. function ScreenTrans(contentRoot, screenClip, startFrame, fastTrans)
  64. {
  65.    this.content = contentRoot;
  66.    this.screen = screenClip;
  67.    this.curFrame = startFrame;
  68.    this.screenFrame = 0;
  69.    this.transitioning = false;
  70.    this.fastTrans = !fastTrans ? false : true;
  71.    this.debug = false;
  72.    if(!this.content)
  73.    {
  74.       trace("ScreenTrans: Content root is undefined");
  75.    }
  76.    if(!this.screen)
  77.    {
  78.       trace("ScreenTrans: Screen clip is undefined");
  79.    }
  80.    if(this.debug)
  81.    {
  82.       trace("ScreenTrans: Initialised");
  83.    }
  84. }
  85. function ContentTrans(contentRoot, arrClips, startFrame, fastTrans)
  86. {
  87.    this.content = contentRoot;
  88.    this.curFrame = startFrame;
  89.    this.transitioning = false;
  90.    this.fastTrans = !fastTrans ? false : true;
  91.    this.debug = false;
  92.    this.contentClips = arrClips;
  93.    if(!this.content)
  94.    {
  95.       trace("ContentTrans: Content root is undefined");
  96.    }
  97.    var _loc2_ = 0;
  98.    while(_loc2_ < this.contentClips.length)
  99.    {
  100.       var _loc3_ = this.contentClips[_loc2_];
  101.       if(!_loc3_)
  102.       {
  103.          trace("ContentTrans: Content clip " + _loc2_ + " is undefined");
  104.       }
  105.       _loc2_ = _loc2_ + 1;
  106.    }
  107.    if(this.debug)
  108.    {
  109.       trace("ContentTrans: Initialised");
  110.    }
  111. }
  112. stop();
  113. Preloader.prototype.evtEnterFrame = function()
  114. {
  115.    var _loc4_ = _root.getBytesLoaded();
  116.    var _loc3_ = _root.getBytesTotal();
  117.    this.preloader.frame = this.preloader.frame + 1;
  118.    this.preloader.onUpdate();
  119.    if(_loc4_ > 10 && _loc3_ > 10)
  120.    {
  121.       this.preloader.totalBytes = _loc3_;
  122.       this.preloader.loadedBytes = _loc4_;
  123.       this.preloader.fractionLoaded = _loc4_ / _loc3_;
  124.       this.preloader.percentLoaded = Math.floor(_loc4_ * 100 / _loc3_);
  125.       if(_loc4_ == _loc3_)
  126.       {
  127.          this.preloader.onLoaded();
  128.          this.onEnterFrame = undefined;
  129.          this.removeMovieClip();
  130.       }
  131.    }
  132.    else
  133.    {
  134.       this.preloader.percentLoaded = 0;
  135.    }
  136.    this.preloader.loadingString = "Loading: " + this.preloader.percentLoaded + "%";
  137. };
  138. Preloader.prototype.onLoaded = function()
  139. {
  140.    _root.gotoAndStop(this.loadedFrame);
  141. };
  142. Preloader.prototype.onUpdate = function()
  143. {
  144.    trace(this.fractionLoaded);
  145. };
  146. ScreenTrans.prototype.goto = function(frame, onTransComplete)
  147. {
  148.    if(this.curFrame == frame)
  149.    {
  150.       if(this.debug)
  151.       {
  152.          trace("ScreenTrans: Transition to \'" + frame + "\' disallowed: Already on this section");
  153.       }
  154.       return undefined;
  155.    }
  156.    if(this.transitioning)
  157.    {
  158.       if(this.debug)
  159.       {
  160.          trace("ScreenTrans: Transition to \'" + frame + "\' disallowed: Already transitioning");
  161.       }
  162.       return undefined;
  163.    }
  164.    if(this.debug)
  165.    {
  166.       trace("ScreenTrans: Transitioning to \'" + frame + "\'");
  167.    }
  168.    this.goingTo = frame;
  169.    this.transitioning = true;
  170.    this.onTransComplete = onTransComplete;
  171.    this.content.objTrans = this;
  172.    this.screen.objTrans = this;
  173.    this.screen.prevFrameNo = this.screen._currentframe;
  174.    this.screen.onEnterFrame = function()
  175.    {
  176.       if(this.debug)
  177.       {
  178.          trace("ScreenTrans: Hiding content (frame " + this._currentframe + ")");
  179.       }
  180.       if(this.prevFrameNo == this._currentframe || this.objTrans.fastTrans)
  181.       {
  182.          this.objTrans.next();
  183.       }
  184.       this.prevFrameNo = this._currentframe;
  185.    };
  186.    this.screen.gotoAndPlay("hide");
  187. };
  188. ScreenTrans.prototype.next = function()
  189. {
  190.    if(this.debug)
  191.    {
  192.       trace("ScreenTrans: Content hidden. Switching to \'" + this.goingTo + "\'");
  193.    }
  194.    this.curFrame = this.goingTo;
  195.    this.goingTo = undefined;
  196.    this.screen.prevFrameNo = this.screen._currentframe;
  197.    this.screen.onEnterFrame = function()
  198.    {
  199.       if(this.debug)
  200.       {
  201.          trace("ScreenTrans: Revealing content (frame " + this._currentframe + ")");
  202.       }
  203.       if(this.prevFrameNo == this._currentframe || this.objTrans.fastTrans)
  204.       {
  205.          this.objTrans.transComplete();
  206.       }
  207.       this.prevFrameNo = this._currentframe;
  208.    };
  209.    this.content.gotoAndStop(this.curFrame);
  210.    this.screen.gotoAndPlay("reveal");
  211. };
  212. ScreenTrans.prototype.transComplete = function()
  213. {
  214.    this.screen.onEnterFrame = undefined;
  215.    this.transitioning = false;
  216.    if(this.fastTrans)
  217.    {
  218.       this.screen.gotoAndStop("idle");
  219.    }
  220.    if(this.onTransComplete != undefined)
  221.    {
  222.       if(this.debug)
  223.       {
  224.          trace("ScreenTrans: Executing callback");
  225.       }
  226.       this.onTransComplete();
  227.    }
  228.    if(this.debug)
  229.    {
  230.       trace("ScreenTrans: Transition complete");
  231.    }
  232. };
  233. ContentTrans.prototype.goto = function(frame, onTransComplete)
  234. {
  235.    if(this.curFrame == frame)
  236.    {
  237.       if(this.debug)
  238.       {
  239.          trace("ContentTrans: Transition to \'" + frame + "\' disallowed: Already on this section");
  240.       }
  241.       return undefined;
  242.    }
  243.    if(this.transitioning)
  244.    {
  245.       if(this.debug)
  246.       {
  247.          trace("ContentTrans: Transition to \'" + frame + "\' disallowed: Already transitioning");
  248.       }
  249.       return undefined;
  250.    }
  251.    if(this.debug)
  252.    {
  253.       trace("ContentTrans: Transitioning to \'" + frame + "\'");
  254.    }
  255.    this.goingTo = frame;
  256.    this.transitioning = true;
  257.    this.onTransComplete = onTransComplete;
  258.    this.content.objTrans = this;
  259.    var _loc2_ = 0;
  260.    while(_loc2_ < this.contentClips.length)
  261.    {
  262.       var _loc3_ = this.contentClips[_loc2_];
  263.       _loc3_.prevFrameNo = -1;
  264.       _loc2_ = _loc2_ + 1;
  265.    }
  266.    this.content.onEnterFrame = function()
  267.    {
  268.       var _loc4_ = true;
  269.       var _loc3_ = 0;
  270.       while(_loc3_ < this.objTrans.contentClips.length)
  271.       {
  272.          var _loc2_ = this.objTrans.contentClips[_loc3_];
  273.          if(!this.objTrans.fastTrans)
  274.          {
  275.             if(_loc2_.prevFrameNo != _loc2_._currentframe)
  276.             {
  277.                _loc4_ = false;
  278.             }
  279.             _loc2_.prevFrameNo = _loc2_._currentframe;
  280.          }
  281.          _loc3_ = _loc3_ + 1;
  282.       }
  283.       if(_loc4_)
  284.       {
  285.          this.objTrans.next();
  286.       }
  287.    };
  288.    _loc2_ = 0;
  289.    while(_loc2_ < this.contentClips.length)
  290.    {
  291.       _loc3_ = this.contentClips[_loc2_];
  292.       _loc3_.gotoAndPlay("out");
  293.       _loc2_ = _loc2_ + 1;
  294.    }
  295. };
  296. ContentTrans.prototype.next = function()
  297. {
  298.    if(this.debug)
  299.    {
  300.       trace("ContentTrans: Content is now out. Switching to \'" + this.goingTo + "\'");
  301.    }
  302.    this.curFrame = this.goingTo;
  303.    this.goingTo = undefined;
  304.    this.content.objTrans = this;
  305.    var _loc2_ = 0;
  306.    while(_loc2_ < this.contentClips.length)
  307.    {
  308.       var _loc3_ = this.contentClips[_loc2_];
  309.       _loc3_.prevFrameNo = -1;
  310.       _loc2_ = _loc2_ + 1;
  311.    }
  312.    this.content.onEnterFrame = function()
  313.    {
  314.       var _loc4_ = true;
  315.       var _loc3_ = 0;
  316.       while(_loc3_ < this.objTrans.contentClips.length)
  317.       {
  318.          var _loc2_ = this.objTrans.contentClips[_loc3_];
  319.          if(!this.objTrans.fastTrans)
  320.          {
  321.             if(_loc2_.prevFrameNo != _loc2_._currentframe)
  322.             {
  323.                _loc4_ = false;
  324.             }
  325.             _loc2_.prevFrameNo = _loc2_._currentframe;
  326.          }
  327.          _loc3_ = _loc3_ + 1;
  328.       }
  329.       if(_loc4_)
  330.       {
  331.          this.objTrans.transComplete();
  332.       }
  333.    };
  334.    this.content.gotoAndStop(this.curFrame);
  335.    _loc2_ = 0;
  336.    while(_loc2_ < this.contentClips.length)
  337.    {
  338.       _loc3_ = this.contentClips[_loc2_];
  339.       _loc3_.gotoAndPlay("in");
  340.       _loc2_ = _loc2_ + 1;
  341.    }
  342. };
  343. ContentTrans.prototype.transComplete = function()
  344. {
  345.    this.content.onEnterFrame = undefined;
  346.    this.transitioning = false;
  347.    if(this.onTransComplete != undefined)
  348.    {
  349.       if(this.debug)
  350.       {
  351.          trace("ContentTrans: Executing callback");
  352.       }
  353.       this.onTransComplete();
  354.    }
  355.    if(this.debug)
  356.    {
  357.       trace("ContentTrans: Transition complete");
  358.    }
  359. };
  360. com.mosesSupposes.fuse.ZigoEngine.simpleSetup(com.mosesSupposes.fuse.Shortcuts,com.mosesSupposes.fuse.PennerEasing);
  361. var objTrans = new ScreenTrans(_root,_root.screen,"preloader");
  362. var loadingComplete = false;
  363. var animComplete = false;
  364. var objPreloader = new Preloader(_root);
  365. objPreloader.onUpdate = function()
  366. {
  367.    _root.loaded.text = "LOADED: " + this.percentLoaded + "%";
  368. };
  369. objPreloader.onLoaded = function()
  370. {
  371.    _root.loadingComplete = true;
  372.    _root.loaded.text = "PREPARING...";
  373.    if(_root.animComplete)
  374.    {
  375.       _root.konggfx.play();
  376.    }
  377. };
  378. setupRightClickMenu();
  379. _root.kongregateServices.connect();
  380. _level0.cmuSWF_ID = "HannaInAChoppa";
  381. if(_global.System)
  382. {
  383.    System.security.allowDomain("www.deeperbeige.com");
  384. }
  385. loadMovieNum("http://www.deeperbeige.com/tracking/tracker.swf?r=" + (Math.floor(Math.random() * 10000) + 10000),19467);
  386.